package com.ttmall.service.impl;

import com.ttmall.common.pojo.TaotaoResult;
import com.ttmall.mapper.TbItemParamItemMapper;
import com.ttmall.pojo.TbItemParamItem;
import com.ttmall.pojo.TbItemParamItemExample;
import com.ttmall.service.ItemParamItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by GalaIO on 2018/1/18.
 */
@Service
public class ItemParamItemServiceImpl implements ItemParamItemService {
    @Autowired
    private TbItemParamItemMapper tbItemParamItemMapper;

    @Override
    public TaotaoResult getItemParamItemByItemId(Long itemId) {
        TbItemParamItemExample example = new TbItemParamItemExample();
        TbItemParamItemExample.Criteria criteria = example.createCriteria();
        criteria.andItemIdEqualTo(itemId);
        List<TbItemParamItem> list = tbItemParamItemMapper.selectByExampleWithBLOBs(example);
        if (list != null && list.size() > 0) {
            return TaotaoResult.ok(list.get(0));
        }
        return TaotaoResult.ok();
    }
}
